import React from 'react'
import end from '../../assets/css/order/end.module.css'

export default class EndComponent extends React.Component {
    constructor(){
        super();
        this.state={
            list:[]
        }
    }
    componentWillMount() {
        let id=localStorage.uid;
        fetch("http://vueshop.glbuys.com/api/order/lastordernum?uid="+id+"&token=1ec949a15fb709370f")
            .then(res=>{
                return res.json()
            }).then(res=>{
            if(res.code===200){
                this.setState({list:res.data})
            }
        })
    }
    goBack(){
        this.props.history.goBack()
    }
    order(){
        this.props.history.push('/user/order/orders')
    }

    render() {
        return(
            <div className={end.boxEnd}>
                <div>
                    <img src={require('../../assets/images/home/goods/back.png')} alt="" onClick={this.goBack.bind(this)}/>
                    <span>确认订单</span>
                </div>
                <div className={end.boxDiv}>
                    <p style={{color:'#E51B19'}}>下单成功！</p>
                    <p style={{color:'#F17F1F'}}>订单编号：{this.state.list.ordernum}</p>
                    <p onClick={this.order.bind(this)}>查看订单</p>
                    <button>去付款</button>
                </div>
            </div>
        )
    }
}